<template>
	<view class="releaseActivity_box box pd" style="padding-bottom: 400rpx;">
		<view class="account_container">
			<view class="account_conatiner_top_bar">
				<view class="" style="margin-right: 20rpx;" @click="goback">
					<image src="../../static/back.png" mode="" style="width: 36rpx;height: 36rpx;"></image>
				</view>
				<view class="">
					发布活动
				</view>
			</view>
			<u-picker :show="showFrom" :columns="columns1" title='请选择活动组织形式' keyName="label"
				@confirm='confirmRegistrationSet(1,$event)' @close='closeRegistrationSet(1)'
				@cancel='closeRegistrationSet(1)' @change='choseRegistrationSet(1,$event)'></u-picker>

			<u-picker :show="showFree" :columns="columns3" title='请选择是否免费' keyName="label"
				@confirm='confirmRegistrationSet(2,$event)' @close='closeRegistrationSet(2)'
				@cancel='closeRegistrationSet(2)' @change='choseRegistrationSet(2,$event)'></u-picker>

			<u-picker :show="showType" :columns="columns2" title='请选择活动分类' keyName="label"
				@confirm='confirmRegistrationSet(3,$event)' @close='closeRegistrationSet(3)'
				@cancel='closeRegistrationSet(3)' @change='choseRegistrationSet(3,$event)'></u-picker>
			<view class="releaseActivity_container">

				<view class="releaseActivity_container_top">
					<image :src="activeData.img" mode="" v-if="activeData.img" style="width:670rpx;height:336rpx;">
					</image>
					<u-upload :fileList="fileList1" @afterRead="select" @delete="deletePic" name="1" multiple
						:maxCount="10" v-else>
						<!-- <uni-file-picker v-model="imageValue" fileMediatype="image" mode="grid" @select="select"
						@progress="progress" @success="success" @fail="fail"
						style="width: 100%;height: 100%;position: relative;"> -->
						<view class="releaseActivity_container_top_img" style="position:absolute;top: 0;">
							<image src="../../static/Publish_ActivityDefault_Status/camera.png" mode=""></image>
						</view>
						<view class=""
							style="text-align:center;position:absolute;bottom:45px;margin:auto;left:0;right: 0;">
							<text>上传活动封面图</text>
						</view>
						<!-- </uni-file-picker> -->
					</u-upload>
				</view>
				<view class="releaseActivity_container_bottom">
					<view class="releaseActivity_container_bottom_item">
						<view class="releaseActivity_container_bottom_item_left">
							活动标题
						</view>
						<view class="releaseActivity_container_bottom_item_right" style="max-width:416rpx;">
							<text @click="toggle('bottom')"><text
									class="button-text">{{activeData.title?activeData.title:"请输入活动标题"}}</text></text>
						</view>
					</view>
					<view class="releaseActivity_container_bottom_item">
						<view class="releaseActivity_container_bottom_item_left">
							活动介绍
						</view>
						<view class="releaseActivity_container_bottom_item_right" style="max-width:416rpx;">
							<text @click="toggleDesc('bottom')"><text
									class="button-text">{{activeData.desc?activeData.desc:"请输入活动介绍"}}</text></text>
						</view>
					</view>
					<view class="releaseActivity_container_bottom_item">
						<view class="releaseActivity_container_bottom_item_left">
							活动地址
						</view>
						<view class="releaseActivity_container_bottom_item_right" style="display: flex;"
							@click="choseLocation">
							<input type="text" v-model="activeData.address" placeholder="请输入活动地址" disabled />
							<image src="../../static/activity/postion.png" mode=""></image>
						</view>
					</view>
					<view class="releaseActivity_container_bottom_item">
						<view class="releaseActivity_container_bottom_item_left">
							开始时间
						</view>
						<view class="releaseActivity_container_bottom_item_right">
							<!-- 2024/02/27 00:00:30 <image src="../../static/Publish_ActivityDefault_Status/date.png"
								mode=""></image> -->
							<uni-datetime-picker returnType="timestamp" v-model="activeData.startTime"
								@change="changeStartTime($event)" />
						</view>
					</view>
					<view class="releaseActivity_container_bottom_item">
						<view class="releaseActivity_container_bottom_item_left">
							结束时间
						</view>
						<view class="releaseActivity_container_bottom_item_right">
							<!-- 2024/02/27 00:00:30 <image src="../../static/Publish_ActivityDefault_Status/date.png"
								mode=""></image> -->
							<uni-datetime-picker returnType="timestamp" v-model="activeData.endTime"
								@change="changeEndTime($event)" />
						</view>
					</view>
					<view class="releaseActivity_container_bottom_item">
						<view class="releaseActivity_container_bottom_item_left">
							报名截止时间
						</view>
						<view class="releaseActivity_container_bottom_item_right">
							<!-- 2024/02/27 00:00:30 <image src="../../static/Publish_ActivityDefault_Status/date.png"
								mode=""></image> -->
							<uni-datetime-picker returnType="timestamp" v-model="activeData.registerEnd"
								@change="changeRegisterEnd($event)" />
						</view>
					</view>
					<view class="releaseActivity_container_bottom_item">
						<view class="releaseActivity_container_bottom_item_left">
							活动组织形式
						</view>
						<view class="releaseActivity_container_bottom_item_right">
							<u-button @click="showFrom = true" v-if='!eventOrganizational'>请选择</u-button>
							<text @click="showFrom = true">{{eventOrganizational}}</text>
						</view>
					</view>
					<view class="releaseActivity_container_bottom_item">
						<view class="releaseActivity_container_bottom_item_left">
							活动分类
						</view>
						<view class="releaseActivity_container_bottom_item_right">
							<u-button @click="showType = true" v-if='!activeType'>请选择</u-button>
							<text @click="showType = true">{{activeType}}</text>
						</view>
					</view>
					<view class="releaseActivity_container_bottom_item">
						<view class="releaseActivity_container_bottom_item_left">
							是否免费
						</view>
						<view class="releaseActivity_container_bottom_item_right">
							<!-- <u-button @click="showFree = true" v-if='!freeData'>请选择</u-button> -->
							<text @click="showFree = true">{{activeData.free?"是":'否'}}</text>
						</view>
					</view>
					<view class="releaseActivity_container_bottom_item" v-if="!activeData.free">
						<view class="releaseActivity_container_bottom_item_left">
							收费金额
						</view>
						<view class="releaseActivity_container_bottom_item_right">
							<input type="text" v-model="activeData.amount" placeholder="请输入收费金额" />
						</view>
					</view>
				</view>
			</view>
		</view>
		<uni-popup ref="popup" background-color="#fff" @change="changePopup">
			<view class="popup_title">
				<view class="popup_top">
					<view class="">
						活动标题
					</view>
					<!-- <view class="">
						<image src="../../static/close.png" mode=""
							style="width: 28rpx;height: 28rpx;margin-right: 50rpx;"></image>
					</view> -->
				</view>
				<view class="popup_center">
					<textarea name="" id="" cols="30" rows="10" v-model="activeData.title"></textarea>
				</view>
				<view class="popup_right" @click="closePopup">
					保存
				</view>
			</view>
		</uni-popup>
		<uni-popup ref="popupDesc" background-color="#fff" @change="changePopupDesc">
			<view class="popup_title">
				<view class="popup_top">
					<view class="">
						活动介绍
					</view>
					<!-- 	<view class="">
						<image src="../../static/close.png" mode=""
							style="width: 28rpx;height: 28rpx;margin-right: 50rpx;"></image>
					</view> -->
				</view>
				<view class="popup_center">
					<textarea name="" id="" cols="30" rows="10" v-model="activeData.desc"></textarea>
				</view>
				<view class="popup_right" @click="closePopup">
					保存
				</view>
			</view>
		</uni-popup>
		<view class="btn_list">
			<view class="btn_list_left" @click="saveActiveMethod">
				<view class="">
					<image src="../../static/Publish_ActivityDefault_Status/save.png" mode=""></image>
				</view>
				<view class="">
					保存草稿
				</view>
			</view>
			<view class="btn_list_canter" @click="viewActive">
				预览活动
			</view>
			<view class="btn_list_right" @click="releaseActivity">
				提交发布
			</view>
		</view>
	</view>
</template>

<script>
	import {
		releaseActivity,
		upLoadFile,
		publishUpdates,
		activityType,
		saveActive,
		getUserPhone,
		activeDetail,
		activeDetailView
	} from "../../api/request.js"
	import {
		gotoLogin
	} from "../../utils/getPhone.js"
	import cityData from '../../utils/cityCode.js';
	export default {
		data() {
			return {
				showFrom: false,
				showType: false,
				showFree: false,
				gotoEventDetailsId: null,
				isSave: false,
				columns1: [
					[{
						label: '线上',
						// 其他属性值
						id: 2
						// ...
					}, {
						label: '线下',
						id: 1
					}]
				],
				columns2: [
					[{
						label: '红色旅游',
						id: 1
					}, {
						label: '社区活动',
						id: 2
					}, {
						label: '团建年会',
						id: 3
					}, {
						label: '文艺演出',
						id: 4
					}, {
						label: '培训活动',
						id: 5
					}, {
						label: '摄影大赛',
						id: 6
					}]
				],
				columns3: [
					[{
						label: '否',
						id: false
					}, {
						label: '是',
						id: true
					}]
				],
				startTime: '',
				endTime: "",
				value: 0,
				freeData: "否",
				eventOrganizational: '线下',
				activeType: '',
				range: [{
						value: 0,
						text: "篮球"
					},
					{
						value: 1,
						text: "足球"
					},
					{
						value: 2,
						text: "游泳"
					},
				],
				titleValue: "",
				descValue: "",
				activeData: {
					id: "",
					typeId: 0,
					title: "",
					img: "",
					free: false,
					amount: "",
					startTime: '',
					endTime: "",
					registerEnd: "",
					desc: "",
					addrName: "",
					lati: 0,
					longi: 0,
					addrDetail: "",
					province: "",
					city: "",
					district: "",
					activityForm: 1,
					cityCode: ''
				},
				choseData: [],
				activeId: null,
				isSearch: false
			};
		},
		async onLoad(e) {
			uni.getStorage({
				key: "hasPhone",
				success(res) {
					console.log(res, 'hasPhone');
					if (res.data == false || !res.data) {
						uni.showToast({
							icon: "none",
							title: "未查询到登录信息，为您跳转登录"
						})
						setTimeout(() => {
							uni.navigateTo({
								url: "/pages/showGetPhone/showGetPhone"
							})
						}, 2000)
					}

				},
				fail(err) {
					uni.navigateTo({
						url: "/pages/showGetPhone/showGetPhone"
					})
				}
			})
			// 判断地理位置是否授权
			function authorizedPositioning(callBack = () => {}) {
				uni.getSystemInfo({ // 获取系统信息
					success(res) {
						let locationEnabled = res.locationEnabled; //判断手机定位服务是否开启
						let locationAuthorized = res.locationAuthorized; //判断定位服务是否允许微信授权
						if (locationEnabled == false || locationAuthorized == false) {
							// GPS 未授权
							callBack("GPSunauthorized");
						} else {
							// GPS 已授权 判断微信定位是否授权
							uni.authorize({
								scope: 'scope.userLocation',
								success() {
									// GPS已授权 微信定位已授权
									uni.getLocation({
										type: 'gcj02',
										success({
											latitude,
											longitude
										}) {
											// latitude; 纬度
											// longitude; 经度
											callBack("Authorized", {
												latitude,
												longitude
											});
										}
									});
								},
								fail() {
									// // GPS已授权 微信定位未授权
									// callBack("WENXINunauthorized");
									// uni.showModal({
									// 	title: '未打开小程序定位',
									// 	content: '找不到您的位置，请开启定位',
									// 	confirmText: '开启定位',
									// 	showCancel: false,
									// 	success: (res) => {
									// 		if (res.confirm) {
									// 			uni.openSetting(); // 打开地图权限设置
									// 		}
									// 	}
									// });
								}
							});
						}
					}
				})
			}
			const that = this
			uni.getStorage({
				key: 'token',
				success: async res => {
					that.token = res.data
				},
				fail: async res => {}
			});

			let res = await activityType()
			let data = authorizedPositioning()
			console.log(data, 'res', res);
			// uni.getLocation({
			// 	success: (res) => {
			// 		console.log(res);
			// 	},
			// 	fail: (err) => {
			// 		console.log(err);
			// 	},
			// 	complete: (res) => {}
			// })
		},
		async onShow() {
			const activeId = getApp().globalData.activeId;
			const id = getApp().globalData.id;
			const search = getApp().globalData.search;
			if (search) {
				this.isSearch = true
				this.activeId = id
				this.getActiveDetail(id)
			}
			if (getApp().globalData.isEdit) {
				getApp().globalData.isEdit = false
				this.activeId = activeId
				this.activeDetailViewMethod(activeId)
			}
			uni.hideTabBar()
		},
		methods: {
			async viewActive() {
				if (this.isSave) {
					let res = await this.saveActiveMethod()
					console.log(this.gotoEventDetailsId);
					uni.navigateTo({
						url: "/pages/eventDetails/eventDetails?id=" + this.gotoEventDetailsId +
							"&isView=true"
					})
				}

			},
			async getActiveDetail(id) {
				let res = await activeDetail(id)
				console.log(res);
				this.activeData = res
			},
			async activeDetailViewMethod(id) {
				let res = await activeDetailView(id)
				console.log(res);
				this.activeData = res
				this.activeData.img = res.image
				this.url = res.image
				this.freeData = res.free
				// if(res.activityForm){
				// 	this.activeType =''
				// }
				// this.eventOrganizational = res.typeId
			},
			getCityCode(cityName) {
				console.log(cityName, 'cityName');
				const cityInfo = cityData.find(city => {
					if (city.cityName == cityName) {
						console.log(city.cityName, cityName);
						return city.cityCode
					}
				});
				console.log(cityInfo, 'cityInfo');
				return cityInfo ? cityInfo.cityCode : null;
			},
			async saveActiveMethod() {
				console.log(this.activeData);
				const {
					addrDetail,
					city,
					cityCode,
					desc,
					district,
					endTime,
					free,
					img,
					lati,
					longi,
					province,
					registerEnd,
					startTime,
					title,
					typeId
				} = this.activeData
				if (!addrDetail || !city || !cityCode || !province || !lati || !district || !longi) {
					uni.showToast({
						icon: "none",
						title: "地址有误，请重新选择"
					})
					return
				}
				if (!desc) {
					uni.showToast({
						icon: "none",
						title: "请输入活动介绍"
					})
					return
				}
				if (!title) {
					uni.showToast({
						icon: "none",
						title: "请输入活动标题"
					})
					return
				}
				if (!startTime) {
					uni.showToast({
						icon: "none",
						title: "请输入活动开始时间"
					})
					return
				}
				if (!endTime) {
					uni.showToast({
						icon: "none",
						title: "请输入活动结束时间"
					})
					return
				}
				if (!registerEnd) {
					uni.showToast({
						icon: "none",
						title: "请输入报名截止时间"
					})
					return
				}
				if (typeId < 0) {
					uni.showToast({
						icon: "none",
						title: "请选择活动分类"
					})
					return
				}
				// if (!free) {
				// 	uni.showToast({
				// 		icon: "none",
				// 		title: "请选择是否免费"
				// 	})
				// 	return
				// }
				if (!img) {
					uni.showToast({
						icon: "none",
						title: "请选择活动封面图"
					})
					return
				}
				let temp = JSON.parse(JSON.stringify(this.activeData))
				let startTime1 = new Date(temp.startTime);
				let endTime2 = new Date(temp.endTime);
				let registerEnd1 = new Date(temp.registerEnd);

				// 格式化日期为 "YYYY-MM-DD HH:mm:ss" 格式
				startTime1 =
					`${startTime1.getFullYear()}-${(startTime1.getMonth() + 1).toString().padStart(2, '0')}-${startTime1.getDate().toString().padStart(2, '0')} ${startTime1.getHours().toString().padStart(2, '0')}:${startTime1.getMinutes().toString().padStart(2, '0')}:${startTime1.getSeconds().toString().padStart(2, '0')}`;
				registerEnd1 =
					`${registerEnd1.getFullYear()}-${(registerEnd1.getMonth() + 1).toString().padStart(2, '0')}-${registerEnd1.getDate().toString().padStart(2, '0')} ${registerEnd1.getHours().toString().padStart(2, '0')}:${registerEnd1.getMinutes().toString().padStart(2, '0')}:${registerEnd1.getSeconds().toString().padStart(2, '0')}`;
				endTime2 =
					`${endTime2.getFullYear()}-${(endTime2.getMonth() + 1).toString().padStart(2, '0')}-${endTime2.getDate().toString().padStart(2, '0')} ${endTime2.getHours().toString().padStart(2, '0')}:${endTime2.getMinutes().toString().padStart(2, '0')}:${endTime2.getSeconds().toString().padStart(2, '0')}`;
				temp.startTime = startTime1
				temp.endTime = endTime2
				temp.registerEnd = registerEnd1
				console.log('saveActiveMethod');
				let res = await saveActive(temp)
				console.log(res, 'res保存');
				this.gotoEventDetailsId = res
				this.isSave = true
				uni.showToast({
					icon: "none",
					title: "保存成功"
				})
			},
			async releaseActivity() {
				const {
					addrDetail,
					city,
					cityCode,
					desc,
					district,
					endTime,
					free,
					img,
					lati,
					longi,
					province,
					registerEnd,
					startTime,
					title,
					typeId
				} = this.activeData
				if (!addrDetail || !city || !cityCode || !province || !lati || !district || !longi) {
					uni.showToast({
						icon: "none",
						title: "地址有误，请重新选择"
					})
					return
				}
				if (!desc) {
					uni.showToast({
						icon: "none",
						title: "请输入活动介绍"
					})
					return
				}
				if (!title) {
					uni.showToast({
						icon: "none",
						title: "请输入活动标题"
					})
					return
				}
				if (!startTime) {
					uni.showToast({
						icon: "none",
						title: "请输入活动开始时间"
					})
					return
				}
				if (!endTime) {
					uni.showToast({
						icon: "none",
						title: "请输入活动结束时间"
					})
					return
				}
				if (!registerEnd) {
					uni.showToast({
						icon: "none",
						title: "请输入报名截止时间"
					})
					return
				}
				if (typeId < 0) {
					uni.showToast({
						icon: "none",
						title: "请选择活动分类"
					})
					return
				}
				// if (!free) {
				// 	uni.showToast({
				// 		icon: "none",
				// 		title: "请选择是否免费"
				// 	})
				// 	return
				// }
				if (!img) {
					uni.showToast({
						icon: "none",
						title: "请选择活动封面图"
					})
					return
				}
				let temp = JSON.parse(JSON.stringify(this.activeData))
				let startTime1 = new Date(temp.startTime);
				let endTime2 = new Date(temp.endTime);
				let registerEnd1 = new Date(temp.registerEnd);

				// 格式化日期为 "YYYY-MM-DD HH:mm:ss" 格式
				startTime1 =
					`${startTime1.getFullYear()}-${(startTime1.getMonth() + 1).toString().padStart(2, '0')}-${startTime1.getDate().toString().padStart(2, '0')} ${startTime1.getHours().toString().padStart(2, '0')}:${startTime1.getMinutes().toString().padStart(2, '0')}:${startTime1.getSeconds().toString().padStart(2, '0')}`;
				registerEnd1 =
					`${registerEnd1.getFullYear()}-${(registerEnd1.getMonth() + 1).toString().padStart(2, '0')}-${registerEnd1.getDate().toString().padStart(2, '0')} ${registerEnd1.getHours().toString().padStart(2, '0')}:${registerEnd1.getMinutes().toString().padStart(2, '0')}:${registerEnd1.getSeconds().toString().padStart(2, '0')}`;
				endTime2 =
					`${endTime2.getFullYear()}-${(endTime2.getMonth() + 1).toString().padStart(2, '0')}-${endTime2.getDate().toString().padStart(2, '0')} ${endTime2.getHours().toString().padStart(2, '0')}:${endTime2.getMinutes().toString().padStart(2, '0')}:${endTime2.getSeconds().toString().padStart(2, '0')}`;
				temp.startTime = startTime1
				temp.endTime = endTime2
				temp.registerEnd = registerEnd1
				console.log(this.activeData, 'activeData', temp);
				let res = await releaseActivity(temp)
				console.log(res, 'releaseActivityactiveData');

				uni.showToast({
					icon: 'none',
					title: "发布成功"
				})
			},
			uploadFile(filePath, token) {
				console.log(filePath, 'filePath');
				return new Promise((resolve, reject) => {
					uni.uploadFile({
						url: 'https://test.hdb168.com/activity/act/upload',
						filePath: filePath,
						name: 'file',
						header: {
							'Content-Type': 'multipart/form-data',
							'Authorization': 'Bearer:' + token
						},
						success: (uploadRes) => {
							console.log(uploadRes, 'uploadRes');
							if (uploadRes.statusCode === 200) {
								resolve(uploadRes.data);
							} else {
								reject(new Error('上传失败'));
							}
						},
						fail: (err) => {
							reject(err);
						}
					});
				});
			},
			deletePic() {},
			async select(e) {
				console.log(e);
				const that = this
				this.uploadFile(e.file[0].thumb, this.token)
					.then(response => {
						that.activeData.img = JSON.parse(response).data
						that.url = JSON.parse(response).data
						console.log('文件上传成功：', response);
					})
					.catch(error => {
						console.error('文件上传失败：', error);
					});
			},
			confirmRegistrationSet(num, e) {
				this.showFrom = false
				this.showType = false
				this.showFree = false
				console.log(num, e);
				if (num == 1) {
					console.log(e, 'eventOrganizational');
					this.eventOrganizational = e.value[0].label
					this.activeData.activityForm = e.value[0].id
				} else if (num == 2) {
					console.log(e, 'freeData');
					this.freeData = e.value[0].label
					this.activeData.free = e.value[0].id
					console.log(e.value[0].id, ' e.value[0].id');
				} else {
					this.activeData.typeId = e.value[0].id
					this.activeType = e.value[0].label
					console.log(e, 'e.value[0].id');
				}
			},
			choseRegistrationSet(num, e) {
				if (num == 1) {
					console.log(e, 'eventOrganizational');
					this.eventOrganizational = e.value[0].id
					console.log(e, 'choseRegistrationSet', e.indexs[0]);
				} else if (num == 2) {
					this.freeData = e.value[0].label
					console.log(e, 'choseRegistrationSet', e.indexs[0]);
					this.activeData.free = e.value[0].id
					console.log(e.value[0].id, ' e.value[0].id');
				} else {
					this.activeType = e.value[0].label
					this.activeData.typeId = e.value[0].id
					console.log(e, 'e.value[0].id');
				}
			},
			closeRegistrationSet(e) {
				this.showFrom = false
				this.showType = false
				this.showFree = false
			},
			choseLocation() {
				let that = this
				uni.chooseLocation({
					success: async function(res) {
						that.activeData.addrName = res.address + res.name
						let parsedData = await that.parseLocationData(that.activeData.addrName)
						console.log(parsedData, 'parsedData');
						if (parsedData) {
							that.activeData.addrName = that.choseData.addrName;
							that.activeData.addrDetail = that.choseData.addrDetail;
							that.activeData.province = that.choseData.province;
							that.activeData.city = that.choseData.city;
							that.activeData.district = that.choseData.district;
							that.activeData.lati = that.choseData.lati;
							that.activeData.longi = that.choseData.longi;
							that.activeData.cityCode = that.getCityCode(that.activeData.city)
						}
						that.activeData.addrDetail = res.name
						that.activeData.addrName = res.address
						that.activeData.lati = res.latitude
						that.activeData.longi = res.longitude
						console.log(res, 'ihsadkjasghdiasgdasjkg');
					},
					fail: function() {
						uni.showToast({
							icon: "error",
							title: "选择位置失败"
						})
						console.log('选择位置失败');
					},
					complete: function() {
						console.log('调用结束');
					}
				});

			},
			changeStartTime() {},
			changeEndTime() {},
			changeRegisterEnd() {},
			goback() {

				if (this.isSearch) {
					const that = this
					uni.navigateBack({
						fail: function(e) {
							if (e) {
								uni.navigateTo({
									url: "/pages/eventDetails/eventDetails?id=" + that.activeId
								});
							}
							// 通过eventChannel向被打开页面传送数据
							console.log(e, that.activeId);
						},
						complete() {
							uni.showTabBar()
						}
					})
				} else {
					uni.navigateBack({
						fail: function(e) {
							if (e) {
								uni.switchTab({
									url: '/pages/index/index'
								});
							}
							// 通过eventChannel向被打开页面传送数据
							console.log(e);
						},
						complete() {
							uni.showTabBar()
						}
					})
				}
			},
			change(e) {
				console.log("e:", e);
			},
			toggle(type) {
				this.type = type
				// open 方法传入参数 等同在 uni-popup 组件上绑定 type属性
				this.$refs.popup.open(type)
			},
			toggleDesc(type) {
				this.type = type
				// open 方法传入参数 等同在 uni-popup 组件上绑定 type属性
				this.$refs.popupDesc.open(type)
			},
			changePopupDesc(e) {
				console.log("descValue:", this.descValue);
			},
			changePopup(e) {
				console.log("e:", e);
			},
			closePopup(e) {
				this.$refs.popup.close()
				this.$refs.popupDesc.close()
				console.log("titleValue:", this.titleValue);
			},
			parseLocationData(locationData) {
				const that = this
				// 使用正则表达式来提取地址信息
				const url =
					`https://restapi.amap.com/v3/geocode/geo?key=49555c23c089363d0ea2751bba7c669b&address=${encodeURIComponent(locationData)}`;

				uni.request({
					url,
					method: 'GET',
					success: res => {
						console.log(res, 'parseLocationData');
						if (res.data.status === '1' && res.data.count > 0) {
							const {
								formatted_address,
								adcode,
								city,
								country,
								district,
								location,
								province
							} = res.data.geocodes[0]
							const locationData = res.data.geocodes[0].formatted_address; // 高德返回的地址数据

							// 在这里解析高德返回的地址数据
							const addrName = formatted_address; // 地址名称
							const addrDetail = locationData; // 详细地址

							// 经纬度
							const lati = location.split(',')[1]; // 纬度
							const longi = location.split(',')[0]; // 经度
							console.log(addrName, addrDetail, district, 'districtdistrict');
							// that.activeData.addrName = addrName;
							// that.activeData.addrDetail = addrDetail;
							that.activeData.province = province;
							that.activeData.city = city;
							that.activeData.district = district;
							// that.activeData.lati = lati;
							// that.activeData.longi = longi;
							that.activeData.cityCode = adcode
						} else {
							uni.showToast({
								icon: "error",
								title: "解析地址失败"
							});
							console.error("解析地址失败！");
							return null;
						}
					},
					fail: error => {
						uni.showToast({
							icon: "error",
							title: "请求失败"
						});
						console.error('请求失败', error);
						return null;
					}
				});
				// const regex = /^(.+?)省(.+?)市(.+?)区(.+?)(.+?)\((.+?)\)/;
				// const matches = locationData.match(regex);
				// if (matches && matches.length === 7) {
				// 	const addrName = matches[5]; // 地址名称
				// 	const addrDetail = matches[6]; // 详细地址

				// 	// 提取省份、城市和区县
				// 	const province = matches[1] + "省";
				// 	const city = matches[2] + '市';
				// 	const district = matches[3] + "区/县";

				// 	// 对于纬度和经度，这里提供示例数值，您需要根据您的情况进行替换
				// 	const lati = 28.1854; // 假设纬度
				// 	const longi = 113.0321; // 假设经度

				// 	return {
				// 		addrName: addrName,
				// 		addrDetail: addrDetail,
				// 		province: province,
				// 		city: city,
				// 		district: district,
				// 		lati: lati,
				// 		longi: longi
				// 	};
				// } else {
				// 	uni.showToast({
				// 		icon: "error",
				// 		title: "请选择具体地址"
				// 	})
				// 	console.error("位置数据格式不正确！");
				// 	return null;
				// }
			}

		},
	}
</script>

<style lang="scss">
	textarea {
		width: 100%;
	}

	.file-picker__box {
		width: 670rpx !important;
		height: 336rpx !important;
	}

	.popup_title {
		display: flex;
		flex-direction: column;

		.popup_top {
			font-family: PingFangSC, PingFang SC;
			font-weight: 500;
			font-size: 32rpx;
			color: #1A1A1A;
			line-height: 32rpx;
			text-align: left;
			font-style: normal;
			margin-left: 40rpx;
			margin-top: 40rpx;
			margin-bottom: 52rpx;
			display: flex;
			justify-content: space-between;
		}

		.popup_center {
			padding: 30rpx;
			width: 90%;
			margin: auto;
			background: #FFFFFF;
			border-radius: 30rpx;
			border: 2rpx solid #EDEDED;
		}

		.popup_right {
			width: 90%;
			margin: auto;
			height: 88rpx;
			text-align: center;
			font-family: PingFangSC, PingFang SC;
			font-weight: 500;
			font-size: 32rpx;
			color: #FFFFFF;
			line-height: 88rpx;
			font-style: normal;
			background: conic-gradient(from 90deg at 50% 0%, #F09583 0%, #F9301C 100%);
			border-radius: 16rpx;
		}
	}

	.btn_list {
		position: fixed;
		bottom: 82rpx;
		width: 100%;
		height: 188rpx;
		background: #FFFFFF;
		box-shadow: 0rpx 0rpx 2rpx 0rpx rgba(15, 26, 62, 0.34);
		border-radius: 32rpx 32rpx 0rpx 0rpx;
		display: flex;
		z-index: 10;

		.btn_list_left {
			margin-left: 52rpx;
			margin-right: 38rpx;
			width: 80rpx;
			display: flex;
			flex-direction: column;
			margin-top: 44rpx;
			height: 88rpx;

			image {
				width: 40rpx;
				height: 40rpx;
			}

			view {
				width: 80rpx;
				height: 24rpx;
				font-family: PingFangSC, PingFang SC;
				font-weight: 500;
				font-size: 20rpx;
				color: #858585;
				line-height: 24rpx;
				text-align: left;
				margin-top: 24rpx;
				font-style: normal;
				text-align: center;
			}
		}

		.btn_list_canter {
			flex: 1;
			height: 88rpx;
			background: #FFFFFF;
			border-radius: 16rpx;
			border: 2rpx solid #EDEDED;
			text-align: center;
			margin-top: 40rpx;
			line-height: 88rpx;
			color: #C5C5C5;
		}

		.btn_list_right {
			flex: 1;
			height: 88rpx;
			margin-right: 28rpx;
			margin-left: 16rpx;
			background: conic-gradient(from 90deg at 50% 0%, #F09583 0%, #F9301C 100%);
			border-radius: 16rpx;
			height: 88rpx;
			line-height: 88rpx;
			color: #FFFFFF;
			margin-top: 40rpx;
			text-align: center;
		}
	}

	.releaseActivity_container_bottom {
		display: flex;
		flex-direction: column;

		.releaseActivity_container_bottom_item {
			display: flex;
			justify-content: space-between;
			margin-top: 60rpx;

			.releaseActivity_container_bottom_item_left {
				font-family: PingFangSC, PingFang SC;
				font-weight: 500;
				font-size: 32rpx;
				color: #000000;
				line-height: 44rpx;
				text-align: left;
				font-style: normal;
			}

			.releaseActivity_container_bottom_item_right {
				text-overflow: ellipsis;
				overflow: hidden;
				white-space: nowrap;
				font-family: PingFangSC, PingFang SC;
				font-weight: 400;
				font-size: 32rpx;
				color: #000000;
				line-height: 44rpx;
				text-align: right;
				font-style: normal;
			}

			image {
				width: 30rpx;
				height: 30rpx;
				margin-left: 28rpx;
			}
		}
	}



	.account_container {
		width: 90%;
		margin: auto;
		margin-top: 88rpx;

		.account_conatiner_top_bar {
			margin-bottom: 20rpx;
			display: flex;
		}
	}

	.releaseActivity_container {
		display: flex;
		flex-direction: column;

		.releaseActivity_container_top {
			margin-bottom: 62rpx;
			margin: auto;
			border: 1px dashed;
			width: 670rpx;
			height: 336rpx;
			background: url("../../static/Publish_ActivityDefault_Status/bg.png") no-repeat;
			background-size: 100%;
			position: relative;

			.releaseActivity_container_top_img {
				margin: auto;
				text-align: center;
				width: 100%;
				height: 100%;

				image {
					margin-top: 122rpx;
					width: 48rpx;
					height: 48rpx;
					margin-bottom: 12rpx;
				}

			}
		}

		.releaseActivity_container_bottom {
			display: flex;
		}
	}
</style>